//Recode some variables
//The Three Bs
***************************2022 Survey Data********************************
clear all
use C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2022 replication data.dta
**Belief
*belheav - 5 point scale belief in heaven
*belhell 
*belgod
*alpha belheav belhell belgod

*Test scale = mean(unstandardized items)

*Average interitem covariance:     1.647092
*Number of items in the scale:            3
*Scale reliability coefficient:      0.9356
gen believe = ((15-(belheav+ belhell+ belgod))/12)



**Belong
*religNet How many of your closest friends are (your religious denomination)
gen belong=religNet

**Behave
*attend Church attendance
*pray
*scripture
*saygrace
*alpha attend pray scripture saygrace

*Test scale = mean(unstandardized items)

*Average interitem covariance:      3.07398
*Number of items in the scale:            4
*Scale reliability coefficient:      0.8665

gen behave =((27-(attend+pray+ scripture+ saygrace))/23)


*************************2024********************************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2024 replication data.dta"

**Belief
Q38 (biblical literalism)
Q45 (religion provides guidance in life)
Q53 (belief in god)
. alpha Q38 Q45 Q53

*Test scale = mean(unstandardized items)

*Average interitem covariance:     .7502395
*Number of items in the scale:            3
*Scale reliability coefficient:      0.6608

gen believe = ((12-(nq38+Q45+nq53))/9)

**Belong
Q41 (friends same church)
Q42 (neighbors same church)
Q43 (family same church)

*Test scale = mean(unstandardized items)
*Reversed item:  Q41

*Average interitem covariance:      .651307
*Number of items in the scale:            3
*Scale reliability coefficient:      0.7090

gen belong = ( Q41+ nq42+ nq43)/12

**Behave
Q37 (church attendance)
Q39 (scripture study)
Q40 (prayer)
*Test scale = mean(unstandardized items)
*Reversed item:  Q39

*Average interitem covariance:     4.149929
*Number of items in the scale:            3
*Scale reliability coefficient:      0.8184

gen nq39 = (9-Q39)
gen behave = ((23-(Q37+ Q40+ nq39))/21)


//Chapter Two Figures
//Figure 2.1
***************************2020 Survey Data********************************
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\Religion-Becoming Scale\BigKU 2020 recoded.dta"
graph bar rb , over(gen) blabel(total)

graph bar rb , over(attend) blabel(total,format(%9.2f) )
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\mean of rb barplot.grec"
graph save "Graph" "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\RB by attend (2020).gph", replace


***************************2022 Survey Data********************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2022 replication data.dta"

graph bar rb , over(gen) blabel(total)



*************************2024********************************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2024 replication data.dta"

graph bar rb , over(gen) blabel(total)
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\RB by generation (2024).png", as(png) name("Graph")as(png) name("Graph")

//Figure 2.2

graph bar rb religiosity secular, over( religaff) blabel(total,format(%9.2f) )
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\figure 2-2 (full).grec"

*One reviewer suggests making this into three separate figures
graph bar rb, over( religaff) blabel(total,format(%9.2f) )
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\figure 2-2.grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\rb by affiliation (2024).png", as(png) name("Graph")

graph bar religiosity, over( religaff) blabel(total,format(%9.2f) )
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\figure 2-2.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\figure 2-2 (religiosity).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\rb by religiosity (2024).png", as(png) name("Graph")

graph bar secular, over( religaff) blabel(total,format(%9.2f) )
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\figure 2-2.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\figure 2-2 (secularism).grec"
graph save "Graph" "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\secular by religaff (2024).gph", replace
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\secular by religaff (2024).png", as(png) name("Graph")

//Figure 2.3
graph bar temperance humanity justice transcendence , over( religaff) blabel(total,format(%9.2f) )
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\figure 2-2 (full).grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\figure 2-3.grec"

//Figure 2.4
graph bar rb religiosity secular, over( Q37) blabel(total,format(%9.2f) )

//Figure 2.5
graph bar rb religiosity secular, over( Q44 ) blabel(total,format(%9.2f) )

//Figure 2.6
graph bar rb religiosity secular, over( Q45 ) blabel(total,format(%9.2f) )

//Figure 2.7
graph bar rb religiosity secular, over( Q54_4 ) blabel(total,format(%9.2f) )

//Figure 2.8
graph bar rb religiosity secular, over( Q55 ) blabel(total,format(%9.2f) )



//Chapter 3

*************************2024********************************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2024 replication data.dta"

**Figure 3.1
reg affpol rb believe belong behave evangelical CN pm12 secular strongpid strongideo Gender educ1 , robust
coefplot, drop(_cons) xline(0) xtitle ("Coefficient Size", size (medium))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Affective Polarization\coefplotlabels (affpol).grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Affective Polarization\coefplotlabels (affpol + educ).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Affective Polarization\analyses\affpol coefplot.png", as(png) name("Graph") replace

**Figure 3.2
reg polsectarian rb believe belong behave evangelical CN pm12 secular strongpid strongideo Gender educ1 , robust
coefplot, drop(_cons) xline(0) xtitle ("Coefficient Size", size (medium))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Affective Polarization\coefplotlabels (affpol).grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Affective Polarization\coefplotlabels (affpol + educ).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Affective Polarization\analyses\polsectarian coefplot.png", as(png) name("Graph") replace

//Chapter 4

//Figure 4.1
***************************2022 Survey Data********************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2022 replication data.dta"

reg CNr RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age
coefplot, drop(_cons) xline(0) levels(90)ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2022).grec"

//Figure 4.2
*************************2024********************************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2024 replication data.dta"
reg CN rb believe belong behave evangelical pm12 secular repub conservative white highrid Gender educ1, robust
coefplot, drop(_cons) xline(0) levels(90)ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2024 Survey).grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2024 Survey + gender).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\CN by RB (2024).png", as(png) name("Graph") replace



//Chapter 5

//Figure 5.1
***************************2022 Survey Data********************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Data\KU Surveys\Big-KU-2022\Big-KU-2022 (affpol).dta"
reg Rdisc RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age
coefplot, drop(_cons) xline(0) levels(90)ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2022).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\Images\Figure 5-1.png", as(png) name("Graph")

//Figure 5.2
reg Wdisc RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age
coefplot, drop(_cons) xline(0) levels(90)ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2022).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\Images\Figure 5-2.png", as(png) name("Graph")

//Figure 5.3
//1st Half of Figure
reg GLdisc RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age
coefplot, drop(_cons) xline(0) ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2022).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\Images\Figure 5-3-1.png", as(png) name("Graph")

//2nd half of figure
reg Tdisc RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age
coefplot, drop(_cons) xline(0) ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2022).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\Images\Figure 5-3-2.png", as(png) name("Graph")

//combine figures in PowerPoint


//Figure 5.4
//1st Half of Figure

*************************************************2024************************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2024 replication data.dta"
reg Atheists RB believe belong behave evangelical pm12 secular repub conservative white highrid Gender educ1, robust
coefplot, drop(_cons) xline(0) ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2024 Survey).grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2024 Survey + gender).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\Images\Figure 5-4-1.png", as(png) name("Graph") replace

//2nd Half of Figure
reg religfund RB believe belong behave evangelical pm12 secular repub conservative white highrid Gender educ1, robust
coefplot, drop(_cons) xline(0) ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2024 Survey).grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2024 Survey + gender).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\Images\Figure 5-4-2.png", as(png) name("Graph") replace

//Figure 5.5
reg tol RB believe belong behave evangelical pm12 secular repub conservative white highrid Gender educ1, robust
coefplot, drop(_cons) xline(0) ciopts(recast(rcap))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2024 Survey).grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2024 Survey + gender).grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\Images\Figure 5-5.png", as(png) name("Graph") replace

//Chapter 6

//Create a coefficient plot for the book (Figure 6.1)
***************************2022 Survey Data********************************
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2022 replication data.dta"

reg Q26_10 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2022).grec"

reg Q26_11 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot (2022).grec"


//I would really like help creating a nice barplot that doesn't involve Microsoft Excel
//grab the predicted values and plot in EXcel. C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Religious Liberty-Democracy in Crisis\Images\Democracy in Crisis barplot



ologit Q26_10 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1, robust
**grab probablities for plotting
mtable, at(RB=(0 1)) atmeans
mtable, at(religiosity=(0 1)) atmeans

ologit Q26_10 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1, robust
**grab probablities for plotting
mtable, at(RB=(0 1)) atmeans
mtable, at(believe=(0 1)) atmeans
mtable, at(belong=(0 1)) atmeans
mtable, at(behave=(0 1)) atmeans

ologit Q26_11 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1, robust
**grab probablities for plotting
mtable, at(RB=(0 1)) atmeans
mtable, at(religiosity=(0 1)) atmeans

ologit Q26_11 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1, robust
**grab probablities for plotting
mtable, at(RB=(0 1)) atmeans
mtable, at(believe=(0 1)) atmeans
mtable, at(belong=(0 1)) atmeans
mtable, at(behave=(0 1)) atmeans

//Figure 6.3
//These are the models
*The other political party is trying to destroy democracy and emergency measures are needed to preserve democracy by keeping the other side out of power
ologit Q26_2 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Religious Liberty-Democracy in Crisis\Figure 6.3 models.doc", replace label ctitle(Emergency Powers) stats(coef se) sym(***,**,*) dec(3)

*It's okay if my political party bends the rules during elections as long as we win.... RB Strongly Disagree
ologit Q26_3 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Religious Liberty-Democracy in Crisis\Figure 6.3 models.doc", label ctitle(Emergency Powers) stats(coef se) sym(***,**,*) dec(3)

*The existing system is corrupt and failing, and we need push for its collapse so that a new era can begin
ologit Q26_6 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Religious Liberty-Democracy in Crisis\Figure 6.3 models.doc", label ctitle(Emergency Powers) stats(coef se) sym(***,**,*) dec(3)

*A time will come when patriotic Americans have to take the law into their own hands
ologit Q26_7 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Religious Liberty-Democracy in Crisis\Figure 6.3 models.doc", label ctitle(Emergency Powers) stats(coef se) sym(***,**,*) dec(3)

*If elected leaders will not protect America, the people must do it themselves, even if it requires violent actions....
ologit Q26_4 RB believe belong behave evangelical RRr repub conservative white highrid Rural gender educ1 age, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Religious Liberty-Democracy in Crisis\Figure 6.3 models.doc", label ctitle(Emergency Powers) stats(coef se) sym(***,**,*) dec(3)



//Violation of Democratic Norms Values in Action
ologit Q26_2 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3 (VIA).doc", replace label ctitle(Emergency Powers) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_3 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3 (VIA).doc", label ctitle(Bend Rules) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_4 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3 (VIA).doc", label ctitle(Protect America) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_6 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online AppendixA-6-3 (VIA).doc", label ctitle(Push Collapse) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_7 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3 (VIA).doc", label ctitle(Vigilante) stats(coef se) sym(***,**,*) dec(3)





 